<?php
require_once( '../../libs/smarty.inc' );
require_once( '../../libs/smt_variables.php' );
require_once( '../../libs/Class_DB.php' );
require_once( '../../libs/Class_ERROR.php' );
require_once( '../../libs/login.inc.php' );
require_once( '../../libs/page.php' );

if( $_SERVER['REQUEST_METHOD'] == 'GET'){

	$forms = $_GET;
	$company_name = $_GET["company_name"];
	$where = '';
	$query = '';
	if($company_name != null){
		$where = $where." and company_name like '%".$company_name."%'";
		$query .="&company_name=".$company_name;
	}
	
	$sql =  "SELECT * FROM p_consumer WHERE 1 = 1 $where order by u_date desc";
	$sqlcount ="SELECT COUNT(*) as cnt FROM p_consumer WHERE 1=1 ".$where;
	$db = new Class_DB;
	$res = $db->query($sql);

	while( $row = mysql_fetch_array($res,MYSQL_ASSOC) ){
		$row['r_date']=$row['r_date']==NULL?"":date('Y/m/d',strtotime($row['r_date']));
		$row['u_date']=$row['u_date']==NULL?"":date('Y/m/d',strtotime($row['u_date']));
		$consumerlist[] = $row;
	}

	$smarty->assign('consumerlist', $consumerlist);
	if( isset( $forms ) ) $smarty->assign('forms', $forms);
}


$menu_html = file_get_contents( $_SERVER['DOCUMENT_ROOT'].'/templates/web-admin/menu.html' );

$smarty->assign('menu_html', $menu_html);

$smarty->assign('shoplist', $shoplist);

$smarty->assign('cnt', $cnt);

$smarty->display('web-admin/consumer_select.html');


?>